import { defineStore } from 'pinia'
import axios from 'axios'
import { ref } from 'vue'

interface PromptRequest {
  text: string
  prompt_type: string
  temperature: number
  max_tokens: number
}

export const usePromptStore = defineStore('prompt', () => {
  const loading = ref(false)
  const error = ref<string | null>(null)

  const generatePrompt = async (params: PromptRequest) => {
    try {
      loading.value = true
      error.value = null
      const response = await axios.post('/api/v1/deepseek/generate_prompt', params)
      return response.data
    } catch (err) {
      error.value = err instanceof Error ? err.message : '生成提示词失败'
      throw err
    } finally {
      loading.value = false
    }
  }

  return {
    loading,
    error,
    generatePrompt
  }
}) 